#include<iostream>
#include<vector>
#include<string>

using namespace std;

void replace(string &s, const string &oldVal, const string &newVal)
{
	int p = 0;
//	cout << s.find(oldVal, p) << endl;
	while((p = s.find(oldVal, p)) != string::npos){
		s.replace(p, oldVal.size(), newVal);
		p += newVal.size();
	}
}

int main(int argc, char const *argv[])
{
	string s = "tho thru tho!";
	replace(s,"thru", "through");
	cout << s << endl;
	return 0;
}
